package org.eu.hdeogratias.license.model;

import java.io.Serializable;
import java.util.Date;
import java.util.Objects;

/**
 * 许可证创建者参数
 *
 * @author weitao
 */
public class LicenseCreatorParam implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 证书 subject
     */
    private String subject;

    /**
     * 密钥（私钥）别称
     */
    private String privateAlias;

    /**
     * 密钥（私钥）密码（需要妥善保管，不能让使用者知道）
     */
    private String keyPass;

    /**
     * 访问秘钥库（私钥）的密码
     */
    private String storePass;

    /**
     * 证书生成路径
     */
    private String licensePath;

    /**
     * 密钥（私钥）库存储路径
     */
    private String privateKeysStorePath;

    /**
     * 证书生效时间
     */
    private Date issuedTime = new Date();

    /**
     * 证书失效时间
     */
    private Date expiryTime;

    /**
     * 用户类型
     */
    private String consumerType = "user";

    /**
     * 用户数量
     */
    private Integer consumerAmount = 1;

    /**
     * 描述信息
     */
    private String description = "";

    /**
     * 额外的 License 校验参数
     */
    private LicenseCheck licenseCheck;

    public String getSubject() {
        return subject;
    }

    public void setSubject(String subject) {
        this.subject = subject;
    }

    public String getPrivateAlias() {
        return privateAlias;
    }

    public void setPrivateAlias(String privateAlias) {
        this.privateAlias = privateAlias;
    }

    public String getKeyPass() {
        return keyPass;
    }

    public void setKeyPass(String keyPass) {
        this.keyPass = keyPass;
    }

    public String getStorePass() {
        return storePass;
    }

    public void setStorePass(String storePass) {
        this.storePass = storePass;
    }

    public String getLicensePath() {
        return licensePath;
    }

    public void setLicensePath(String licensePath) {
        this.licensePath = licensePath;
    }

    public String getPrivateKeysStorePath() {
        return privateKeysStorePath;
    }

    public void setPrivateKeysStorePath(String privateKeysStorePath) {
        this.privateKeysStorePath = privateKeysStorePath;
    }

    public Date getIssuedTime() {
        return issuedTime;
    }

    public void setIssuedTime(Date issuedTime) {
        this.issuedTime = issuedTime;
    }

    public Date getExpiryTime() {
        return expiryTime;
    }

    public void setExpiryTime(Date expiryTime) {
        this.expiryTime = expiryTime;
    }

    public String getConsumerType() {
        return consumerType;
    }

    public void setConsumerType(String consumerType) {
        this.consumerType = consumerType;
    }

    public Integer getConsumerAmount() {
        return consumerAmount;
    }

    public void setConsumerAmount(Integer consumerAmount) {
        this.consumerAmount = consumerAmount;
    }

    public String getDescription() {
        return description;
    }

    public void setDescription(String description) {
        this.description = description;
    }

    public LicenseCheck getLicenseCheck() {
        return licenseCheck;
    }

    public void setLicenseCheck(LicenseCheck licenseCheck) {
        this.licenseCheck = licenseCheck;
    }

    @Override
    public String toString() {
        return "LicenseCreatorParam{" +
                "subject='" + subject + '\'' +
                ", privateAlias='" + privateAlias + '\'' +
                ", keyPass='" + keyPass + '\'' +
                ", storePass='" + storePass + '\'' +
                ", licensePath='" + licensePath + '\'' +
                ", privateKeysStorePath='" + privateKeysStorePath + '\'' +
                ", issuedTime=" + issuedTime +
                ", expiryTime=" + expiryTime +
                ", consumerType='" + consumerType + '\'' +
                ", consumerAmount=" + consumerAmount +
                ", description='" + description + '\'' +
                ", licenseCheck=" + licenseCheck +
                '}';
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;

        LicenseCreatorParam that = (LicenseCreatorParam) o;
        if (!Objects.equals(subject, that.subject)) return false;
        if (!Objects.equals(privateAlias, that.privateAlias)) return false;
        if (!Objects.equals(keyPass, that.keyPass)) return false;
        if (!Objects.equals(storePass, that.storePass)) return false;
        if (!Objects.equals(licensePath, that.licensePath)) return false;
        if (!Objects.equals(privateKeysStorePath, that.privateKeysStorePath)) return false;
        if (!Objects.equals(issuedTime, that.issuedTime)) return false;
        if (!Objects.equals(expiryTime, that.expiryTime)) return false;
        if (!Objects.equals(consumerType, that.consumerType)) return false;
        if (!Objects.equals(consumerAmount, that.consumerAmount)) return false;
        if (!Objects.equals(description, that.description)) return false;
        return Objects.equals(licenseCheck, that.licenseCheck);
    }

    @Override
    public int hashCode() {
        int result = subject != null ? subject.hashCode() : 0;
        result = 31 * result + (privateAlias != null ? privateAlias.hashCode() : 0);
        result = 31 * result + (keyPass != null ? keyPass.hashCode() : 0);
        result = 31 * result + (storePass != null ? storePass.hashCode() : 0);
        result = 31 * result + (licensePath != null ? licensePath.hashCode() : 0);
        result = 31 * result + (privateKeysStorePath != null ? privateKeysStorePath.hashCode() : 0);
        result = 31 * result + (issuedTime != null ? issuedTime.hashCode() : 0);
        result = 31 * result + (expiryTime != null ? expiryTime.hashCode() : 0);
        result = 31 * result + (consumerType != null ? consumerType.hashCode() : 0);
        result = 31 * result + (consumerAmount != null ? consumerAmount.hashCode() : 0);
        result = 31 * result + (description != null ? description.hashCode() : 0);
        result = 31 * result + (licenseCheck != null ? licenseCheck.hashCode() : 0);
        return result;
    }
}
